export const namespace = "marketingCoupon";
import { Space } from "antd";

export const calcColumns = (params) => {
  const { operate, venueArr } = params;
  let venueNames = {};
  venueArr.forEach((v) => {
    venueNames[v.id] = v.venueName;
  });
  const columns = [
    {
      title: "ID",
      hidden: process.env.UMI_ENV == "prod" ? true : false,
      width: 180,
      dataIndex: "id",
      hideInSearch: true,
    },
    {
      title: "优惠券类型",
      dataIndex: "couponType",
      valueEnum: {
        1: { text: "满减券" },
        2: { text: "抵用券" },
      },
    },
    {
      title: "优惠券面值",
      dataIndex: "couponParValue",
      valueType: "money",
      hideInSearch: true,
    },
    {
      title: "使用数量",
      dataIndex: "usedCount",
      hideInSearch: true,
    },
    {
      title: "可用场馆",
      dataIndex: "venueId",
      hideInSearch: true,
      render: (_, records) => {
        const { venueId } = records;
        let name = venueId
          .split(",")
          .map((s) => {
            return venueNames[s];
          })
          .join(",");
        return <Space>{name}</Space>;
      },
    },
    {
      title: "使用范围",
      dataIndex: "useScope",
      hideInSearch: true,
      render: (_, records) => {
        const { useScope } = records;
        let valueEnum = {
          "1": "私教课",
          "2": "团课",
          "3": "班课",
          "4": "会员卡",
        };
        let name = useScope
          .split(",")
          .map((s) => {
            return valueEnum[s];
          })
          .join(",");
        return <Space>{name}</Space>;
      },
    },

    // {
    //   title: '更新人',
    //   dataIndex: 'updateBy',
    //   hideInSearch: true

    // },
    // {
    //   title: '更新时间',
    //   dataIndex: 'updateTime',
    //   hideInSearch: true
    // },
    // {
    //   title: '营业状态',
    //   dataIndex: 'state',
    //   hideInSearch: true,
    //   // render: (state) => {
    //   //   return state ? <Tag border={false}>已启动</Tag> : <Tag color='#f0f'>禁用</Tag>
    //   // },
    //   valueEnum: {
    //     all: { text: '全部', status: 'Default' },
    //     close: { text: '关闭', status: 'Default' },
    //     running: { text: '运行中', status: 'Processing' },
    //     online: { text: '已上线', status: 'Success' },
    //     error: { text: '异常', status: 'Error' },
    //   },
    // },
  ];

  columns.push(operate);
  return columns;
};
